package com.warrantyhotel.android.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.warrantyhotel.android.R;
import com.warrantyhotel.android.widget.CustomTextView;

public class GridAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private int[] images;
	private String[] itemName;

	public GridAdapter(Context context, int[] images, String[] itemName) {

		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.itemName = itemName;
		this.images = images;
	}

	public int getCount() {
		return images.length;
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View itemView;
		ImageView imageView = null;
		CustomTextView textView = null;
		if (convertView == null) { // if it's not recycled, initialize some
									// attributes
			itemView = mInflater.inflate(R.layout.grid_item, null);
			imageView = (ImageView) itemView.findViewById(R.id.image_item_grid);
			textView = (CustomTextView) itemView.findViewById(R.id.text_item_grid);
			textView.setTextColor(Color.BLACK);
			imageView.setImageResource(images[position]);
			textView.setText(itemName[position]);
		} else {
			itemView = (View) convertView;
		}

		return itemView;
	}

}
